﻿@using NFine.Domain._02_ViewModel
@{
    ViewBag.Title = "创建订单";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<style>
    .pro, .pro tr, .pro tr td, .pro tr th {
        border: 1px solid #ddd;
        line-height: 30px;
        text-align: center;
    }

    .proShow, .proShow tr, .proShow tr td, .proShow tr th {
        border: 1px solid #ddd;
        line-height: 30px;
        text-align: center;
    }

    .num {
        width: 50px;
        text-align: center;
        float: left;
        height: 30px;
    }

    .setnum {
        border: 1px solid rgb(169,169,169);
        display: block;
        width: 24.5px;
        text-align: center;
        height: 30px;
        line-height: 30px;
    }
</style>
<form id="form1">
    <table class="form" style="width:500px">

        <tr>
            <th class="formTitle">中转中心</th>
            <td class="formValue">
                <select id="F_TransferCenterId" class="form-control required">
                    <option value="">选择中转中心</option>
                    @if (ViewData["TransferCenterList"] != null)
                    {
                        foreach (var entity in (List<View_User_Zhzh>)ViewData["TransferCenterList"])
                        {
                            <option value="@entity.F_Id" data-jf-num="@entity.jfcount">@entity.F_RealName</option>
                        }
                    }

                </select>
            </td>

        </tr>

        <tr>
            <th class="formTitle">品鉴积分</th>
            <td class="formValue">
                <span id="pjint"></span>
            </td>

        </tr>

        <tr>
            <th class="formTitle">消耗积分</th>
            <td class="formValue">
                <input id="jlint" name="jlint" type="number" class="form-control required" placeholder="请输入积分数值" value="" />
            </td>

        </tr>
        <tr>
            <td colspan="2" align="center">
                <a id="btn_finish" class="btn btn-default" onclick="submitForm()">完成</a>
            </td>
        </tr>
    </table>
</form>
<script>
    $(function () {
        $("#F_TransferCenterId").change(function () {
            if ($(this).val()) {
                $("#pjint").text($(this).children('option:selected').attr("data-jf-num"));
            }
            else {
                $("#pjint").text("");
            }
        });
    });

    function submitForm() {
        if (!$("#F_TransferCenterId").val())
        {
            $.modalAlert('请选择中转中心！', "error");
            return;
        }
        var val=$("#jlint").val();
        if (!val||val.length==0)
        {
            $.modalAlert('请输入积分消耗数量！', "error");
            return;
        }
        var vale = parseFloat(val);
        if (!vale || vale <= 0 || vale > parseFloat($("#pjint").text()))
        {
            $.modalAlert('消耗数量不能小于0或超过当前积分！', "error");
            return;
        }
        var postData = { 'uid': ''+$("#F_TransferCenterId").val()+'', 'pjint': $("#pjint").text(), 'jlint': vale };
        $.submitForm({
            url: "/BizManage/ZhongZhuanPinJian/SubmitForm",
            param: postData,
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        });
    }

</script>
